﻿// Connect_PLC_Dlg.cpp: 实现文件
//

#include "pch.h"
#include "SakerProject.h"
#include "Connect_PLC_Dlg.h"
#include "afxdialogex.h"

#include "xxFileProcess.h"
#include "mmFile_Paras.h"



// CConnect_PLC_Dlg 对话框
CConnect_PLC_Dlg * m_Connect_PLC;

IMPLEMENT_DYNAMIC(CConnect_PLC_Dlg, CDialogEx)

CConnect_PLC_Dlg::CConnect_PLC_Dlg(CWnd* pParent /*=nullptr*/)
	: CDialogEx(IDD_Connect_PLC, pParent)
{

}

CConnect_PLC_Dlg::~CConnect_PLC_Dlg()
{
}

void CConnect_PLC_Dlg::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
}


BEGIN_MESSAGE_MAP(CConnect_PLC_Dlg, CDialogEx)
	ON_BN_CLICKED(IDC_BUTTON_Connect, &CConnect_PLC_Dlg::OnBnClickedButtonConnect)
	ON_BN_CLICKED(IDC_BUTTON_Save, &CConnect_PLC_Dlg::OnBnClickedButtonSave)
END_MESSAGE_MAP()


// CConnect_PLC_Dlg 消息处理程序


void CConnect_PLC_Dlg::OnBnClickedButtonConnect()
{
	// TODO: 在此添加控件通知处理程序代码
}


BOOL CConnect_PLC_Dlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();
	//mmConnect_PLC.IPAddress = xx::InitWidget(this, IDC_IPADDRESS, mmConnect_PLC.iniField, L"IPaddress", mmFile_Paras.iniModelPath(), L"");
	//mmConnect_PLC.Flag_AutoConnect = xx::InitCK(this, IDC_CHECK_AutoConnect, mmConnect_PLC.iniField, L"AutoConnect", mmFile_Paras.iniModelPath(), TRUE);
	//
	xx::InitCK(this, IDC_CHECK_CONNEC_POWER, mmConnect_COMPower->iniField, L"PowerAutoConnect", mmFile_Paras.iniModelPath(), true);
	xx::InitWidget(this, IDC_EDIT_POWERCOM, mmConnect_COMPower->iniField, L"PowerCOM_Port", mmFile_Paras.iniModelPath(), 0);
	xx::InitWidget(this, IDC_EDIT_BAUDRATE, mmConnect_COMPower->iniField, L"PowerCOM_BaudRate", mmFile_Paras.iniModelPath(), 0);
	xx::InitWidget(this, IDC_EDIT_READ_CH, mmConnect_COMPower->iniField, L"PowerCOM_ReadCH", mmFile_Paras.iniModelPath(), 0);

	return TRUE;
}


void CConnect_PLC_Dlg::OnBnClickedButtonSave()
{
	//mmConnect_PLC.IPAddress = xx::DefaultWidget(this, IDC_IPADDRESS, mmConnect_PLC.iniField, L"IPaddress", mmFile_Paras.iniModelPath(), L"");
	//mmConnect_PLC.Flag_AutoConnect = xx::DefaultCK(this, IDC_CHECK_AutoConnect, mmConnect_PLC.iniField, L"AutoConnect", mmFile_Paras.iniModelPath());

	mmConnect_COMPower->Flag_AutoConnect = xx::DefaultCK(this, IDC_CHECK_CONNEC_POWER, mmConnect_COMPower->iniField, L"PowerAutoConnect", mmFile_Paras.iniModelPath());
	mmConnect_COMPower->iPort = xx::DefaultWidget(this, IDC_EDIT_POWERCOM, mmConnect_COMPower->iniField, L"PowerCOM_Port", mmFile_Paras.iniModelPath(), 0);
	mmConnect_COMPower->iBaudRate = xx::DefaultWidget(this, IDC_EDIT_BAUDRATE, mmConnect_COMPower->iniField, L"PowerCOM_BaudRate", mmFile_Paras.iniModelPath(), 0);
	mmConnect_COMPower->iReadCH = xx::DefaultWidget(this, IDC_EDIT_READ_CH, mmConnect_COMPower->iniField, L"PowerCOM_ReadCH", mmFile_Paras.iniModelPath(), 0);

}
